#!/bin/bash

cd ../build/

start_time=$(date +%s) # %s可以计算的是1970年以来的秒数

# Request distributions
#for dist in sequential hotspot latest exponential; do
#    sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
##    ./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-33M-10M_${dist}_dist.txt > ../evaluation/ar_16_llsm_${dist}_dist.txt
#    ./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-33M-10M_${dist}_dist.txt > ../evaluation/ar_16_llsm_${dist}_dist.txt
#    ./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-c-33M-10M_${dist}_dist.txt > ../evaluation/ar_16_baseline_${dist}_dist.txt
#done
#
#for dist in uniform zipfian sequential hotspot latest exponential; do
#    sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
#    ./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-20M-10M_${dist}_dist.txt > ../evaluation/osm_16_llsm_${dist}_dist.txt
#    ./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-20M-10M_${dist}_dist.txt > ../evaluation/osm_16_llsm_${dist}_dist.txt
#    ./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-c-20M-10M_${dist}_dist.txt > ../evaluation/osm_16_baseline_${dist}_dist.txt
#done

# idf_351_valid
for wl in d e; do
  for dist in uniform zipfian sequential hotspot latest exponential; do
      sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
      ./read_cold -f ../db/ali_single_valid_index/idf_351_valid.txt -k 19 -v 64 -d ../ssd/db_idf_351_valid_19_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-${wl}-650K0-10M0_${dist}.txt > ../evaluation/idf_351_valid_19_llsm_${wl}_${dist}.txt
      ./read_cold -f ../db/ali_single_valid_index/idf_351_valid.txt -k 19 -v 64 -d ../ssd/db_idf_351_valid_19_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-${wl}-650K0-10M0_${dist}.txt > ../evaluation/idf_351_valid_19_baseline_${wl}_${dist}.txt
  done


  # idf_175_valid
  for dist in uniform zipfian sequential hotspot latest exponential; do
      sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
      ./read_cold -f ../db/ali_single_valid_index/idf_175_valid.txt -k 19 -v 64 -d ../ssd/db_idf_175_valid_19_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-${wl}-1M3-10M0_${dist}.txt > ../evaluation/idf_175_valid_19_llsm_${wl}_${dist}.txt
      ./read_cold -f ../db/ali_single_valid_index/idf_175_valid.txt -k 19 -v 64 -d ../ssd/db_idf_175_valid_19_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-${wl}-1M3-10M0_${dist}.txt > ../evaluation/idf_175_valid_19_baseline_${wl}_${dist}.txt
  done
done


cd ../learned-leveldb/
python3 ./scripts/collect_results.py 3 > ../evaluation/expr_request_dist_idf_singles_valid_19_random.txt
cat ../evaluation/expr_request_dist_idf_singles_valid_19_random.txt

end_time=$(date +%s)
cost_time=$((end_time-start_time))
echo "$(basename "$0") runs for $((cost_time/60))min $((cost_time%60))s"

